from PySide2.QtCore import *  # type: ignore
from PySide2.QtGui import *  # type: ignore
from PySide2.QtWidgets import *  # type: ignore
import json
import config


class Ui_Dialog(object):
    def __init__(self) -> None:
        self.lang_json = config.read_json(f"{config.path}/locale/lang.json")

    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName("MainWindow")
        MainWindow.resize(396, 185)
        MainWindow.setStyleSheet(
            "\n"
            "background-color: rgb(59, 59, 59);\n"
            "color: rgb(255, 255, 255);\n"
            ""
        )
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayout_2 = QHBoxLayout(self.centralwidget)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label_2 = QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        print(f"{config.path}/images/V.png")
        self.label_2.setPixmap(QPixmap(f"{config.path}/images/V.png"))

        self.horizontalLayout.addWidget(self.label_2)

        self.label = QLabel(self.centralwidget)
        self.label.setObjectName("label")

        self.horizontalLayout.addWidget(self.label)

        self.verticalLayout.addLayout(self.horizontalLayout)

        self.checkBox = QCheckBox(self.centralwidget)
        self.checkBox.setObjectName("checkBox")

        self.verticalLayout.addWidget(self.checkBox)

        self.buttonBox = QDialogButtonBox(self.centralwidget)
        self.buttonBox.setObjectName("buttonBox")
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)

        self.verticalLayout.addWidget(self.buttonBox)

        self.horizontalLayout_2.addLayout(self.verticalLayout)

        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)

    # setupUi

    def retranslateUi(self, MainWindow):
        # print(self.lang_json)
        label_mess = self.lang_json["label_mess"][config.lang_os]
        label_cheek = self.lang_json["label_cheek"][config.lang_os]
        MainWindow.setWindowTitle(
            QCoreApplication.translate("MainWindow", "MainWindow", None)
        )
        self.label_2.setText("")
        self.label.setText(QCoreApplication.translate("MainWindow", label_mess, None))
        self.checkBox.setText(
            QCoreApplication.translate("MainWindow", label_cheek, None)
        )

    # retranslateUi

    def read_json(self, name) -> dict:
        with open(name) as f:
            d = json.load(f)
            return d
